function ensureLeadingSlash(url) {
    if (!url.startsWith('/')) {
      return '/' + url
    }
    return url
}

export const navigateTo = (url) => {
    uni.navigateTo({ url: ensureLeadingSlash(url) })
}

export const reLaunch = (url) => {
   uni.reLaunch({ url: ensureLeadingSlash(url) })
}

export const switchTab = (url) => {
    uni.switchTab({ url: ensureLeadingSlash(url) })
}

export const redirectTo = (url) => {
    uni.redirectTo({ url: ensureLeadingSlash(url) })
}

export const navigateBack = (delta = 1) => {
    uni.navigateBack({ delta })
}